package coml.jiyun.hp.mvpextract.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import coml.jiyun.hp.mvpextract.R;
import coml.jiyun.hp.mvpextract.bean.NaviBean;

public class RlvMainAdapter extends RecyclerView.Adapter {

    private ArrayList<NaviBean.DataBean> dataBeans;

    public RlvMainAdapter(ArrayList<NaviBean.DataBean> dataBeans) {
        this.dataBeans = dataBeans;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item, parent, false);
        return new VH(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        VH vh = (VH) holder;
        ((VH) holder).mTv.setText(dataBeans.get(position).getName());
    }

    @Override
    public int getItemCount() {
        return dataBeans.size();
    }

    class  VH extends RecyclerView.ViewHolder{

        @BindView(R.id.tv)
        TextView mTv;

        public VH(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
